import { BaseEntity } from "src/baseEntity";
import { Dept } from "src/dept/dept.entity";
import { System } from "src/system/system.entity";
import { UserSys } from "src/user/userSys.entity";
import { Work } from "src/work/work.entity";
import { Column, Entity, JoinTable, ManyToMany, ManyToOne, OneToMany } from "typeorm";

export enum ProjectStatus {
    running = "running",
    pause = "pause",
    finished = "finished",
    done = "done"
}

@Entity("project")
export class Project extends BaseEntity {
    @ManyToOne(() => System)
    system: System

    @OneToMany(() => Work, type => type.project)
    works: Work[]

    @Column()
    name: string

    @Column({
        type: "enum",
        enum: ProjectStatus,
        default: ProjectStatus.pause
    })
    status: ProjectStatus

    @Column({ comment: "总量", type: "double" })
    estimate: number

    @Column({ comment: "单条得分", type: "double" })
    score: number

    //项目负责人
    @ManyToMany(() => UserSys)
    @JoinTable()
    responsibility: UserSys[]

    //执行人
    @ManyToMany(() => UserSys)
    @JoinTable()
    user: UserSys[]

    @Column({ nullable: true })
    comment: string

    finished: number
}